package com.rayc.mall.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.rayc.mall.common.exception.BadRequestException;
import lombok.Getter;

/**
 * @Author: Ray-C
 * @CreateTime: 2025-03-23
 * @Description: 用户状态
 * @Version: 1.0
 */
@Getter
public enum UserStatus {
    FROZEN(0, "已注销"),
    NORMAL(1, "正常");

    @EnumValue
    @JsonValue
    final int value;
    final String desc;

    UserStatus(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static UserStatus of(int value) {
        switch (value) {
            case 0:
                return FROZEN;
            case 1:
                return NORMAL;
            default:
                throw new BadRequestException("账户状态错误");
        }
    }
}